<template>
	<rx-dialog @ok="handleSubmit" @cancel="cancel">
		<rx-layout>
            <template #middle>
				<a-form layout="vertical" :model="measureConf" :label-col="labelCol" :wrapper-col="wrapperCol">
					<a-row>
						<a-col :span="12">
							<a-form-item :label="screenLangI18n('common.fieldLabel','字段备注')" style="width:85%">
								<a-input v-model:value="measureConf.fieldLabel"></a-input>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item :label="screenLangI18n('common.aggregate','聚合方式')" style="width:85%">
								<a-select v-model:value="measureConf.aggregate" :getPopupContainer="p=>p.parentNode" >
									<a-select-option value="COUNT">{{screenLangI18n('form.count','计数')}}(COUNT)</a-select-option>
									<a-select-option value="COUNTD">{{screenLangI18n('form.deCount','去重计数')}}(COUNTD)</a-select-option>
									<a-select-option value="SUM">{{screenLangI18n('form.sum','求和')}}(SUM)</a-select-option>
									<a-select-option value="AVG">{{screenLangI18n('form.average','均值')}}(AVG)</a-select-option>
									<a-select-option value="MAX">{{screenLangI18n('form.maxValue','最大值')}}(MAX)</a-select-option>
									<a-select-option value="MIN">{{screenLangI18n('form.minValue','最小值')}}(MIN)</a-select-option>
									<a-select-option value="NONE">{{screenLangI18n('form.not','无')}}(NONE)</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
					</a-row>
                    <a-row>
                        <a-col :span="12">
                            <a-form-item :label="screenLangI18n('common.sort','排序')">
                                <a-radio-group v-model:value="measureConf.sort">
                                    <a-radio value="default">{{screenLangI18n('common.default','默认')}}</a-radio>
                                    <a-radio value="DESC">{{screenLangI18n('common.desOrder','降序')}}(DESC)</a-radio>
                                    <a-radio value="ASC">{{screenLangI18n('common.ascOrder','升序')}}(ASC)</a-radio>
                                </a-radio-group>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12" v-if="showStacked">
                            <a-form-item :label="screenLangI18n('common.noStacked','不堆积')">
                                <a-switch size="small" v-model:checked="measureConf.noStacked"></a-switch>
                            </a-form-item>
                        </a-col>
                    </a-row>
					<a-row>
						<a-col :span="12">
							<a-form-item  :label="screenLangI18n('common.chartType','图表类型')" style="width:85%" v-if="config.chartType=='lineBar'">
								<a-select v-model:value="measureConf.chartType" :getPopupContainer="p=>p.parentNode" >
									<a-select-option value="line">折线</a-select-option>
									<a-select-option value="bar">柱状</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
					</a-row>
				</a-form>
			</template>
		</rx-layout>
	</rx-dialog>
</template>

<script>
import {Util,RxLayout,RxDialog} from "@lowcode/jpaas-base-lib";

export default {
	name: "MeasureConf",
	props:['destroy',"measure","config"],
	components:{
		RxLayout,
		RxDialog
	},
	data() {
		return {
			labelCol: { span: 6 },
			wrapperCol: { span: 16 },
			measureConf:{
				fieldLabel:"",
				chartType:"line",
				formatter:"notFormat",
				decimal:"notHandle",
				prefix:"",
				suffix:"",
				halfAdjust:false,
				aggregate:""
			},
            showStacked:false
		}
	},
	created() {
		this.init();
	},
	methods: {
		screenLangI18n(name,text,key){
			return this.$ti18(name,text,"screenLang",key);
		},
		init(){
			this.measureConf=Object.assign(this.measureConf,this.measure);
			//堆积图
			if(this.config.chartType=="stackedBar"){
                this.measureConf.noStacked=this.measureConf.noStacked?true:false;
			    this.showStacked=true;
            }
		},
		handleSubmit() {
			Util.closeWindow(this, "ok",this.measureConf);
		},
		cancel() {
			Util.closeWindow(this, "cancel");
		},
	},
	watch: {}
}
</script>

<style scoped>
</style>
